﻿// See https://aka.ms/new-console-template for more information
using _01coreLogger;
using CommonCater;
using Microsoft.Extensions.Logging;
using System.Reflection.Emit;
using System.Text;




//1.创建日志工厂
//ILoggerFactory factory = LoggerFactory.Create(a=>a.AddConsole());

////创建日志对象
////ILogger<sqlconnection> logger = factory.CreateLogger<sqlconnection>();

//sqlconnection sql = new sqlconnection(factory);
//sql.Connectionstring();
//string path = Environment.CurrentDirectory;
//Console.WriteLine(path);


//路径  不能写死
//获取到项目的路径
//string path = Environment.CurrentDirectory;

////E:\c#体系课\05三层项目-餐饮管理系统\code\餐饮管理系统\CommonCater\bin\Debug

//int o = path.IndexOf("餐饮管理系统");
//o = path.IndexOf("餐饮管理系统", o + 6);
////路径的截取
//if (o != -1)
//{
//    path = path.Substring(0, o + 6);
//    //:\c#体系课\05三层项目-餐饮管理系统
//}
////:\c#体系课\05三层项目-餐饮管理系统
//Directory.CreateDirectory(path + "\\logger");
//Console.WriteLine("创建文件夹成功");

//string Newpath = $"{path}\\logger\\{DateTime.Now.Year.ToString()}年{DateTime.Now.Month.ToString()}月{DateTime.Now.Day.ToString()}日.txt";
//var sw= File.CreateText(Newpath);
//Console.WriteLine("创建文件成功");
//sw.Close();
//string level = "debug";
//string msg = "123";

//Thread.Sleep(2000);

//msg = $"{level}  {DateTime.Now.ToString()}       {msg}+\r\n";
//byte[] buffer = Encoding.UTF8.GetBytes(msg);
//using (FileStream file = new FileStream(Newpath, FileMode.OpenOrCreate, FileAccess.Write))
//{
//    file.Write(buffer, 0, buffer.Length);
//}
//Console.WriteLine("写入成功");

//log<Program>.LogDebug("debug");



//修改存放路径问题  如果找得到就存在餐饮管理系统 里面 如果找不到就存在当前项目里面
string path = @"E:\c#体系课\05三层项目-餐1饮1管1理1系统111\code\餐1饮1管1理1系1统\CommonCater\bin\Debug";
int o = path.LastIndexOf("餐饮管理系统");
if (o!=-1)
{
    path = path.Substring(0, o + 6);
}

